
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yysk_app/model/common_model/get_certification_type_model.dart';
import 'package:yysk_app/net/api/common_api.dart';
import 'package:yysk_app/net/http.dart';
import 'package:yysk_app/pages/main/main_page.dart';
import 'package:yysk_app/pages/nft_pages/setting/setting_controller.dart';
import 'package:yysk_app/routes/global_controller.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/widget/image_asset_widget.dart';
import 'package:yysk_app/widget/custom_app_bar2.dart';


class SettingRealNameInfo extends StatefulWidget {
  static const path = '/realNameInfo';
  const SettingRealNameInfo({super.key});
  @override
  State<SettingRealNameInfo> createState() => _SettingRealNameInfo();
 }

class _SettingRealNameInfo extends State<SettingRealNameInfo>{
   // final SettingController controller = Get.find();
  final GlobalController globalController = Get.find();
  
  @override 
  void initState() {
    // TODO: implement initState
    super.initState();
    updateUserInfo();
  }
  final infoDetail = Rx<GetCertificationTypeModel?>(null);
  @override
  Widget build(BuildContext context) {
   double top = MediaQuery.of(context).padding.top;

    return PopScope(
      canPop: false,
      child: Scaffold(
        
        body: Stack(
          children: [
               SizedBox(
                          width: context.width,
                          child: ImageAssetWidget(
                            width: 375.px,
                            height: 812.px,
                            imageUrl: 'static/images/bg.png',
                          ),
                        ),
            Padding(padding: EdgeInsets.only(top: top),
              child: Column(
                children: [
                 
                   CustomAppBar2(
                      title: '实名认证',
                      context: context,
                      beforBack: () {
                         try{
                             Get.until((route) => Get.currentRoute == MainPage.path,);
                         }catch(e){
                            Get.offAllNamed(MainPage.path);
                         }
                      },
                    ),
                 
                    hiSpace(height: 10), 
                    Expanded(child: _listView(context: context),)
                ],
              ),
            )
          ],
        ),
      ),
     
    );
  }

  Future<dynamic> updateUserInfo() async {
    final res = http.netFetch<GetCertificationTypeModel>(
      CommonApi.getCertificationType,
      method: Method.post,
      success: (r) {
        infoDetail.value = r.data;
        return r;
      },
    );
    return res;
  }
  _listView({required BuildContext context})
  {
    return ListView(
        padding: EdgeInsets.fromLTRB(0.px, 0.px, 0.px, 0),
        children: [
           SizedBox(
              width: context.width,
              child: Center(
                child: ImageAssetWidget(
                width: 124.px,
                height: 129.px,
                imageUrl: 'static/images/setting/complete_icon@2x.png',
                ),
              ),
          ),
          SizedBox(
            width: context.width,
            height: 30,
            child: Center(
              child: Text('已实名认证',style: TextStyle(fontSize: 16.px,color:AppColors.fontColor),)
            ),
          ),
          hiSpace(height: 50),
         Container(
           margin: EdgeInsets.symmetric(horizontal: 15),
           padding: EdgeInsets.all(16.px),
           decoration: BoxDecoration(
            color: Color.fromRGBO(31, 33,38, 1),
            borderRadius: BorderRadius.circular(10.px),
            border: Border.all(width: 1.px,color: Color.fromRGBO(59, 62, 69, 1))
           ),
          
           child: Row(
            children: [
                SizedBox(
                  width: 88.px,
                  child:    Column(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Padding(
                    padding: EdgeInsets.symmetric(vertical: 10.px),
                    child: Text(
                      '姓名',
                      textAlign: TextAlign.left,
                      style: TextStyle(color: AppColors.fontColor, fontSize: 14.px),

                      ),
                  ),
                     SizedBox(height: 8.px,),
                    Container(width: 88.px,height: 0.5.px,color: AppColors.backgroundColorGrey,),
                       SizedBox(height: 8.px,),
                   Padding(
                    padding: EdgeInsets.symmetric(vertical: 10.px),
                    child: Text(
                      '身份证号',     
                      textAlign: TextAlign.left,
                      style: TextStyle(color: AppColors.fontColor, fontSize: 14.px),

                      ),
                  ),
                  //   Divider(color: Color(0xFFDFDFDF),thickness: 0.01,),

                  //  Padding(
                  //   padding: EdgeInsets.symmetric(vertical: 10),
                  //   child: Text(
                  //     '有效期至',
                  //     textAlign: TextAlign.left,
                  //     style: TextStyle(color: Color(0xFF3D3D3D), fontSize: 14.px),

                  //     ),
                  // ),
                ],
              ),
           
                ),
              Obx(()=>  Expanded(
                flex: 2,
                child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Padding(
                    padding: EdgeInsets.symmetric(vertical: 10),
                    child: Text(
                      infoDetail.value?.name??'',
                      style: TextStyle(color: AppColors.fontColor, fontSize: 14.px),

                      ),
                  ),
                  SizedBox(height: 8.px,),
                            Container(width: context.width,height: 0.5.px,color: AppColors.backgroundColorGrey,),
                            SizedBox(height: 8.px,),
                   Padding(
                    padding: EdgeInsets.symmetric(vertical: 10),
                    child: Text(
                      infoDetail.value?.cardId??'',
                      style: TextStyle(color: AppColors.fontColor, fontSize: 14.px),

                      ),
                  ),
                  // Divider(color: Color(0xFFDFDFDF),thickness: 0.5,),

                  //  Padding(
                  //   padding: EdgeInsets.symmetric(vertical: 10),
                  //   child: Text(
                  //     '有效期至',
                  //     style: TextStyle(color: Color(0xFF3D3D3D), fontSize: 14.px),

                  //     ),
                  // ),
                ],
               ),
              ),
             ) 
            ],
           ),
         ),
         hiSpace(height: 35),

        
        ],
      );
  }

}